<!DOCTYPE>
<html>
<head>
	<title>Page Visibility API</title>
</head>
<body>
	<p id="output"></p>
	<script type="text/javascript" src="EventUtil.js"></script>
	<script type="text/javascript">
		EventUtil.addHandler(document, "msvisibilitychange", handleVisibilityChange);
		EventUtil.addHandler(document, "webkitvisibilitychange", handleVisibilityChange);

		function handleVisibilityChange() {
			var output = document.getElementById("output"),
				msg;
			if (document.hidden || document.msHidden || document.webkitHidden) {
				msg = "Page is now hidden. " + new Date() + "<br>";
			}
			else {
				msg = "Page is now visible. " + new Date() + "<br>";
			}
			output.innerHTML += msg;
		}
	</script>
</body>
</html>